package com.logictech.lims.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import org.jeecgframework.p3.core.utils.common.PageList;
import org.jeecgframework.p3.core.utils.common.PageQuery;
import org.jeecgframework.p3.core.utils.common.Pagenation;

import com.logictech.lims.service.LogService;
import com.logictech.lims.service.PositionService;
import com.logictech.lims.entity.Position;
import com.logictech.lims.dao.PositionDao;

@Service("positionService")
public class PositionServiceImpl implements PositionService {
	@Resource
	private PositionDao positionDao;
	
	@Resource
	private LogService logService;
	
	@Override
	public void doAdd(Position position) {
		positionDao.add(position);
		logService.doAdd("1",position);
	}

	@Override
	public void doEdit(Position position) {
		positionDao.update(position);
		logService.doAdd("2",position);
	}

	@Override
	public void doDelete(String id) {
		Position position  = positionDao.get(id);
		logService.doAdd("3",position);
		position.setDeleteFlag("1");
		positionDao.update(position);
	}

	@Override
	public Position queryById(String id) {
		Position position  = positionDao.get(id);
		return position;
	}

	@Override
	public PageList<Position> queryPageList(
		PageQuery<Position> pageQuery) {
		PageList<Position> result = new PageList<Position>();
		Integer itemCount = positionDao.count(pageQuery);
		List<Position> list = positionDao.queryPageList(pageQuery,itemCount);
		Pagenation pagenation = new Pagenation(pageQuery.getPageNo(), itemCount, pageQuery.getPageSize());
		result.setPagenation(pagenation);
		result.setValues(list);
		return result;
	}

	@Override
	public List<Position> queryByType(String storageType) {
		// TODO Auto-generated method stub
		return positionDao.queryByType(storageType);
	}
	
}
